﻿Imports System.Windows.Forms

Public Class frmLogProposta

    Private Enum eTipoLog As Int32
        Aviso = 0
        Erro = 1
    End Enum

    Private arLog As New ArrayList

    Public WriteOnly Property Log As ArrayList
        Set(ByVal value As ArrayList)
            arLog = value
        End Set
    End Property

    Private Sub configurarGridLog()
        Try

            With Me.dgvLog
                .DataSource = Nothing
                .AutoGenerateColumns = False
                .AllowUserToAddRows = False
                .AllowUserToResizeColumns = False
                .AllowUserToResizeRows = True
                .Columns.Clear()

                Dim colTipo As New DataGridViewImageColumn()
                With colTipo
                    .HeaderText = ""
                    .DataPropertyName = ""
                    .Width = 20
                    .Frozen = True
                    .ReadOnly = True
                    .Visible = False
                    .SortMode = DataGridViewColumnSortMode.NotSortable
                End With
                .Columns.Add(colTipo)

                Dim colImagem As New DataGridViewImageColumn()
                With colImagem
                    .HeaderText = ""
                    .DataPropertyName = ""
                    .Width = 20
                    .Frozen = True
                    .ReadOnly = True
                    .Visible = True
                    .SortMode = DataGridViewColumnSortMode.NotSortable
                End With
                .Columns.Add(colImagem)

                Dim colDescricao As New DataGridViewTextBoxColumn()
                With colDescricao
                    .HeaderText = "Descricao"
                    .DataPropertyName = "descricao"
                    .Width = 500
                    .ReadOnly = True
                    .Visible = True
                    .ValueType = System.Type.GetType("System.String")
                    .SortMode = DataGridViewColumnSortMode.NotSortable
                    .DefaultCellStyle.WrapMode = DataGridViewTriState.True
                End With
                .Columns.Add(colDescricao)

            End With

        Catch ex As Exception
            MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

    End Sub

    Private Sub carregarGridLog()
        Dim iAvisos As Int32
        Dim iErro As Int32
        Dim iTipoLog As eTipoLog

        Try

            For iContadorMensagens = 0 To Me.arLog(DSFronteiraPadrao.frmPadrao.eMensagem.Codigo).Count - 1
                With dgvLog
                    .Rows.Add()
                    iTipoLog = arLog(DSFronteiraPadrao.frmPadraoBanner.eMensagem.TipoLog).item(iContadorMensagens)
                    .Item(0, .Rows.Count - 1).Value = iTipoLog

                    If iTipoLog = eTipoLog.Aviso Then
                        iAvisos += 1
                    Else
                        iErro += 1
                    End If
                    .Item(2, .Rows.Count - 1).Value = arLog(DSFronteiraPadrao.frmPadraoBanner.eMensagem.Mensagem).item(iContadorMensagens)
                End With

            Next

        Catch ex As Exception
            MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub


    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub frmLogProposta_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Me.configurarGridLog()

    End Sub
End Class
